package states;

import flash.geom.Matrix;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.FlxState;
import flixel.group.FlxSpriteGroup;
import flixel.text.FlxText;
import flixel.util.FlxColor;

/**
 * ...
 * @author pchan
 */
class PlayState extends FlxState
{
	static inline public var RED:Int = 1;
	static inline public var BLUE:Int = 2;

	static inline public var WIDTH:Int = 2;
	static inline public var HEIGHT:Int = 2;

	private var _grid:Array<Array<Int>> = [
		[ RED, BLUE ],
		[ BLUE, RED ]
	];
	
	private var _spriteGrid:FlxSpriteGroup;
	
	/**
     * Function that is called up when to state is created to set it up.
     */
    override public function create():Void
    {
		FlxG.mouse.visible = true;

		_spriteGrid = new FlxSpriteGroup();
		for (i in 0...WIDTH) {
			for (j in 0...HEIGHT) {
				var _fx:FlxSprite = new FlxSprite();
				_fx.makeGraphic(100, 100, (_grid[i][j] == RED) ? FlxColor.RED : FlxColor.BLUE);
				_fx.setPosition(i * 100, j * 100);
				_spriteGrid.add(_fx);
			}
		}

        super.create();
    }

    /**
     * Function that is called when this state is destroyed - you might want to 
     * consider setting all objects this state uses to null to help garbage collection.
     */
    override public function destroy():Void
    {
        super.destroy();
    }

    /**
     * Function that is called once every frame.
     */
    override public function update():Void
    {
        super.update();
    }

	/**
	 * This is where we do the actual drawing logic for the game state
	 */
	override public function draw():Void
	{
		// This draws all the game objects
		super.draw();

		// draw the scaled-up contents of the FX buffer back onto the screen:
		_spriteGrid.draw();
	}
}